﻿using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugar;

namespace Ocelot.Admin.Api.Core
{
    /// <summary>
    /// 路由表
    ///</summary>
    [SugarTable("Route")]
    public class Route
    {
        /// <summary>
        /// 主键ID 
        ///</summary>
        [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 项目Id 
        ///</summary>
        [SugarColumn(ColumnName = "ProjectId")]
        public int ProjectId { get; set; }

        /// <summary>
        /// 下游的路由模板，即真实处理请求的路径模板 
        ///</summary>
        [SugarColumn(ColumnName = "DownstreamPathTemplate")]
        public string DownstreamPathTemplate { get; set; }

        /// <summary>
        /// 上游请求的模板，即用户真实请求的链接 
        ///</summary>
        [SugarColumn(ColumnName = "UpstreamPathTemplate")]
        public string UpstreamPathTemplate { get; set; }

        /// <summary>
        /// 上游请求的http方法（数组：GET、POST、PUT） 
        ///</summary>
        [SugarColumn(ColumnName = "UpstreamHttpMethod")]
        public string UpstreamHttpMethod { get; set; }

        /// <summary>
        /// 下游请求的http方法（数组：GET、POST、PUT） 
        ///</summary>
        [SugarColumn(ColumnName = "DownstreamHttpMethod")]
        public string DownstreamHttpMethod { get; set; }

        /// <summary>
        ///  下游Http版本 
        ///</summary>
        [SugarColumn(ColumnName = "DownstreamHttpVersion")]
        public string DownstreamHttpVersion { get; set; }

        /// <summary>
        ///  请求Id 
        ///</summary>
        [SugarColumn(ColumnName = "RequestIdKey")]
        public string RequestIdKey { get; set; }

        /// <summary>
        ///  开启上下游路由模板大小写匹配 
        ///</summary>
        [SugarColumn(ColumnName = "RouteIsCaseSensitive")]
        public bool? RouteIsCaseSensitive { get; set; }

        /// <summary>
        ///  服务名 
        ///</summary>
        [SugarColumn(ColumnName = "ServiceName")]
        public string ServiceName { get; set; }

        /// <summary>
        ///  服务命名空间 
        ///</summary>
        [SugarColumn(ColumnName = "ServiceNamespace")]
        public string ServiceNamespace { get; set; }

        /// <summary>
        /// 请求的方式，如：http,htttps 
        ///</summary>
        [SugarColumn(ColumnName = "DownstreamScheme")]
        public string DownstreamScheme { get; set; }

        /// <summary>
        /// 请求缓存过期时间（需使用Ocelot.Cache.CacheManager） 
        ///</summary>
        [SugarColumn(ColumnName = "Cache_TtlSeconds")]
        public int? CacheTtlseconds { get; set; }

        /// <summary>
        /// 缓存区域（需使用Ocelot.Cache.CacheManager） 
        ///</summary>
        [SugarColumn(ColumnName = "Cache_Region")]
        public string CacheRegion { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Qos_ExceptionsAllowedBeforeBreaking")]
        public int? QosExceptionsallowedbeforebreaking { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Qos_DurationOfBreak")]
        public int? QosDurationofbreak { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Qos_TimeoutValue")]
        public int? QosTimeoutvalue { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "LoadBalancer_Type")]
        public string LoadbalancerType { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "LoadBalancer_Key")]
        public string LoadbalancerKey { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "LoadBalancer_Expiry")]
        public int? LoadbalancerExpiry { get; set; }

        /// <summary>
        /// 是否启用流量限制
        ///</summary>
        [SugarColumn(ColumnName = "RateLimit_EnableRateLimiting")]
        public bool? RatelimitEnableratelimiting { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "RateLimit_Period")]
        public string RatelimitPeriod { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "RateLimit_PeriodTimespan")]
        public decimal? RatelimitPeriodtimespan { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "RateLimit_Limit")]
        public long? RatelimitLimit { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "RateLimit_WhiteList")]
        public string RatelimitWhitelist { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Authentication_AuthenticationProviderKey")]
        public string AuthenticationAuthenticationproviderkey { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Authentication_AllowedScopes")]
        public string AuthenticationAllowedscopes { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "HttpHandler_AllowAutoRedirect")]
        public bool? HttphandlerAllowautoredirect { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "HttpHandler_UseCookieContainer")]
        public bool? HttphandlerUsecookiecontainer { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "HttpHandler_UseTracing")]
        public bool? HttphandlerUsetracing { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "HttpHandler_UseProxy")]
        public bool? HttphandlerUseproxy { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "HttpHandler_MaxConnectionsPerServer")]
        public int? HttphandlerMaxconnectionsperserver { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "UpstreamHost")]
        public string UpstreamHost { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Key")]
        public string Key { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "DelegatingHandlers")]
        public string DelegatingHandlers { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Priority")]
        public int? Priority { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Timeout")]
        public int? Timeout { get; set; }

        /// <summary>
        /// 评估危险服务验证 
        ///</summary>
        [SugarColumn(ColumnName = "DangerousAcceptAnyServerCertificateValidator")]
        public bool? DangerousAcceptAnyServerCertificateValidator { get; set; }
        
        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Security_IPAllowedList")]
        public string SecurityIpallowedlist { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Security_IPBlockedList")]
        public string SecurityIpblockedlist { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        [SugarColumn(ColumnName = "Sort")]
        public int? Sort { get; set; }

        /// <summary>
        ///  
        ///</summary>
        [SugarColumn(ColumnName = "Enabled")]
        public bool Enabled { get; set; }

        /// <summary>
        /// 路由地址配置
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(RouteHostPort.RouteId))]
        public List<RouteHostPort> RouteHostPorts { get; set; }

        /// <summary>
        /// 路由属性
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(RouteProperty.RouteId))]
        public List<RouteProperty> RouteProperties { get; set; }
    }
}
